<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	import="it.polimi.swim.entity.SystemUser, it.polimi.swim.entity.Skill,java.util.List"
	
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="myStyle.css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<div id='header' name = "header">
	<div style="float:left"><a href="index.jsp">SWIMv2</a></div>
	<div style="float:right;"><a href="AvailableSkillsServlet?path=/registrationForm.jsp">Sign up to SWIMv2</a></div>
</div>
<div id="content">
	<br><br><br>
	<fieldset class="fieldsetIndex">
	<legend>Login</legend>
		<form method="post" action="LoginServlet">
			User <br><input type="text" name="mail"/><br>
			Password <br><input type="password" name="psw"/><br>
			<input type="submit" value="Enter">
		</form>
	</fieldset>
	<br><br>
	<fieldset class="fieldsetIndex">
		<legend>Search a user</legend>
		<table>
		<tr><td>
		<form method="post" action="SearchServlet" class="searchIndex">
			<label>Search by Name</label><br>
			<input type="text" name="user" value="Name Surname" />
			<input type="hidden" name="action" value="searchUser">
			<input type="submit" value="Search">
		</form>
		</td></tr><br>
		
		<tr><td>
		<br>
		<form method="post" action="SearchServlet"  class="searchIndex">
		<label>Search by Skill</label><br>
		<%
		if(request.getAttribute("skillList")!=null){
			List<Skill> skillList=(List<Skill>)request.getAttribute("skillList");
			
			out.println("<select name='skill'>");
			for(Skill s:skillList ){
				out.println("<option value="+s.getId()+">"+s.getName()+"</option>");
			}
			out.println("</select>");
		}
		%>
		<input type="submit" value="Search"> 
		<input type="hidden" name="action" value="usersBySkill">
		</form>
		</td></tr>
		</table>
	</fieldset>
	<%
	String err = (String) request.getAttribute("errorMessage");
	if(err!=null){%>
	<script>
	window.alert(<%out.print(err);%>);
	</script>
	<%} 
	if(request.getAttribute("skillList")==null)
		response.sendRedirect("AvailableSkillsServlet?path=/index.jsp");
	%>
</div>
</body>
</html>